/*
 *  Copyright (c) 2011, StripBandunk and/or its affiliates. All rights reserved.
 * 
 *       http://stripbandunk.com/
 * 
 *  STRIPBANDUNK PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.stripbandunk.tutorial.simpleapp.util;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author echo
 */
public final class SpringUtilities {

    private static final ClassPathXmlApplicationContext applicationContext;

    static {
        applicationContext = new ClassPathXmlApplicationContext("/com/stripbandunk/tutorial/simpleapp/resources/applicationContext.xml");
        applicationContext.registerShutdownHook();
    }

    public static ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    public static <T> T getBean(Class<T> clazz) {
        return getApplicationContext().getBean(clazz);
    }

    public static <T> T getBean(Class<T> clazz, String bean) {
        return getApplicationContext().getBean(bean, clazz);
    }
}
